package cn.lili.controller.promotion;

import cn.lili.common.security.AuthUser;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.promotion.entity.dos.TicketDown;
import cn.lili.modules.promotion.entity.vos.CouponVO;
import cn.lili.modules.promotion.service.TicketDownService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @author xiangqian
 * @version 1.0
 * @data 2023/12/14 15:45
 */
@RestController
@Api(tags = "门票领取")
@RequestMapping("/promotion/ticketDown")
@RequiredArgsConstructor
public class TicketDownController {

    @Resource
    private TicketDownService ticketDownService;

    @ApiOperation(value = "添加门票领取")
    @PostMapping
    public ResultMessage<Boolean> addTicketDown(@RequestBody TicketDown ticketDown) {
        //AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
        //ticketDown.setUserId(currentUser.getExtendId());
        //currentUser.setUsername(currentUser.getExtendName());
        return ResultUtil.data(ticketDownService.addTicketDown(ticketDown));
    }

    @ApiOperation(value = "检测是否领取门票")
    @GetMapping("/checkTicketDown/{openId}")
    public ResultMessage<Boolean> checkTicketDown(@PathVariable String openId) {
        //AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
        return ResultUtil.data(ticketDownService.checkTicketDown(openId));
    }
}
